<?php

namespace app\common\business;

use app\common\model\FeedbackField as FeedbackFieldModel;
use think\facade\Log;

class FeedbackField extends CommonBase
{
    private $_feedbackFieldObj = null;

    public function __construct(string $websiteCode)
    {
        $this->_websiteCode      = $websiteCode;
        $this->_feedbackFieldObj = new FeedbackFieldModel([], $websiteCode);
    }

    public function getAllFeedbackField(array $where = []): array
    {
        $res = [];
        try {
            $rows = $this->_feedbackFieldObj->getAllFeedbackField($where);
            foreach ($rows as $row) {
                if (in_array($row['code'], ['status', 'created_at'])) {
                    continue;
                }
                $res[] = $row;
            }
        } catch (\Exception $e) {
            logErr('读取自定义表单的所有字段失败(前台)', sprintf('websiteCode:%s,method:%s,err:%s', $this->_websiteCode, __METHOD__, $e->getMessage()));
        }

        return $res;
    }
}